package com.jspgou.cms.entity;

import java.util.HashSet;
import java.util.Set;

import com.jspgou.cms.entity.base.BaseStore;



public class Store extends BaseStore {
	private static final long serialVersionUID = 1L;

/*[CONSTRUCTOR MARKER BEGIN]*/
	public Store () {
		super();
	}

	/**
	 * Constructor for primary key
	 */
	public Store (java.lang.Long id) {
		super(id);
	}

	/**
	 * Constructor for required fields
	 */
	public Store (
		java.lang.Long id,
		com.jspgou.cms.entity.ShopMember member,
		com.jspgou.cms.entity.StoreModel storeModel,
		java.util.Date createDate,
		java.util.Date sortDate,
		java.lang.Integer priority,
		java.lang.Boolean recommend,
		java.lang.Boolean forbidden,
		java.lang.Boolean modelpermission,
		java.lang.Boolean examine) {

		super (
			id,
			member,
			storeModel,
			createDate,
			sortDate,
			priority,
			recommend,
			forbidden,
			modelpermission,
			examine);
	}

/*[CONSTRUCTOR MARKER END]*/
	
	public String getStoreName() {
		StoreExt ext = getStoreExt();
		if (ext != null) {
			return ext.getStoreName();
		} else {
			return null;
		}
	}
	
	public String getShortName() {
		StoreExt ext = getStoreExt();
		if (ext != null) {
			return ext.getShortName();
		} else {
			return null;
		}
	}
	
	public String getCode() {
		StoreExt ext = getStoreExt();
		if (ext != null) {
			return ext.getCode();
		} else {
			return null;
		}
	}
	
	public String getDomain() {
		StoreExt ext = getStoreExt();
		if (ext != null) {
			return ext.getDomain();
		} else {
			return null;
		}
	}
	
	public String getStorePath() {
		StoreExt ext = getStoreExt();
		if (ext != null) {
			return ext.getStorePath();
		} else {
			return null;
		}
	}
	
	public String getUrl(){
		StoreExt ext = getStoreExt();
		if (ext != null) {
			String url=null;
	         url="http://"+ext.getDomain()+":"+this.getWebsite().getGlobal().getPort()+this.getWebsite().getGlobal().getContextPath();
			return url;
		} else {
			return null;
		}
	}
	
	public String getPostcode() {
		StoreExt ext = getStoreExt();
		if (ext != null) {
			return ext.getPostcode();
		} else {
			return null;
		}
	}
	
	public String getLicenseImg() {
		StoreExt ext = getStoreExt();
		if (ext != null) {
			return ext.getLicenseImg();
		} else {
			return null;
		}
	}
	
	public String getFacadeImg() {
		StoreExt ext = getStoreExt();
		if (ext != null) {
			return ext.getFacadeImg();
		} else {
			return null;
		}
	}
	
	public String getReverseImg() {
		StoreExt ext = getStoreExt();
		if (ext != null) {
			return ext.getReverseImg();
		} else {
			return null;
		}
	}
	
	public String getLogoImg() {
		StoreExt ext = getStoreExt();
		if (ext != null) {
			return ext.getLogoImg();
		} else {
			return null;
		}
	}
	
	public String getStoreAdImg() {
		StoreExt ext = getStoreExt();
		if (ext != null) {
			return ext.getStoreAdImg();
		} else {
			return null;
		}
	}
	
	public String getAddress() {
		StoreExt ext = getStoreExt();
		if (ext != null) {
			return ext.getAddress();
		} else {
			return null;
		}
	}
	
	public String getMobile() {
		StoreExt ext = getStoreExt();
		if (ext != null) {
			return ext.getMobile();
		} else {
			return null;
		}
	}
	
	public String getPartner() {
		StoreExt ext = getStoreExt();
		if (ext != null) {
			return ext.getPartner();
		} else {
			return null;
		}
	}
	
	public String getSellerKey() {
		StoreExt ext = getStoreExt();
		if (ext != null) {
			return ext.getSellerKey();
		} else {
			return null;
		}
	}
	
	public String getSellerEmail() {
		StoreExt ext = getStoreExt();
		if (ext != null) {
			return ext.getSellerEmail();
		} else {
			return null;
		}
	}
	
	public String getIntro() {
		StoreExt ext = getStoreExt();
		if (ext != null) {
			return ext.getIntro();
		} else {
			return null;
		}
	}
	
	public String getTxt() {
		StoreTxt txt = getStoreTxt();
		if (txt != null) {
			return txt.getTxt();
		} else {
			return null;
		}
	}

	public String getTxt1() {
		StoreTxt txt = getStoreTxt();
		if (txt != null) {
			return txt.getTxt1();
		} else {
			return null;
		}
	}

	public String getTxt2() {
		StoreTxt txt = getStoreTxt();
		if (txt != null) {
			return txt.getTxt2();
		} else {
			return null;
		}
	}

	public String getTxt3() {
		StoreTxt txt = getStoreTxt();
		if (txt != null) {
			return txt.getTxt3();
		} else {
			return null;
		}
	}
	
	public StoreTxt getStoreTxt() {
		Set<StoreTxt> set = getStoreTxtSet();
		if (set != null && set.size() > 0) {
			return set.iterator().next();
		} else {
			return null;
		}
	}
	
	public void setStoreTxt(StoreTxt txt) {
		Set<StoreTxt> set = getStoreTxtSet();
		if (set == null) {
			set = new HashSet<StoreTxt>();
			setStoreTxtSet(set);
		}
		if (!set.isEmpty()) {
			set.clear();
		}
		set.add(txt);
	}
	
	public void addToMembers(ShopMember member) {
		Set<ShopMember> members = getMembers();
		if (members == null) {
			members = new HashSet<ShopMember>();
			setMembers(members);
		}
		members.add(member);
//		member.getStores().add(this);
	}
	
	public void addToFullGives(FullGive fullGive) {
		Set<FullGive> set =getFullGives();
		if (set == null) {
			set = new HashSet<FullGive>();
			setFullGives(set);
		}
		set.add(fullGive);
	}


}